package com.botann.projects.base;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.apache.log4j.Logger;

import java.util.List;

/**
 * Charging
 * BaseImp
 * Created by 刘山国 on 2017/11/22.
 * Copyright (c) 2017 刘山国. All rights reserved
 */
public abstract class BaseImp implements LoggerIntf {
    protected Logger logger = Logger.getLogger(loggerClass());

    protected <T> List jsonToListModel(String jsonStr, Class clazz) { // 1 把对象字符串 转为对象集合
        return JSONArray.parseArray(jsonStr).toJavaList(clazz);
    }

    protected <T> T jsonToModel(String jsonStr, Class clazz) {      //把JSON字符串转化为model,怎么转的在架包中有的，不用管
        return (T)JSON.toJavaObject(JSON.parseObject(jsonStr),clazz);
    }

}
